#include "../include/thread_pool.h"

//

int shared_res_init(sharedRes_t *sharedRes, int workernum) {
    // 数据库初始化
    db_conn_pool_init(&sharedRes->dbconnectPool, workernum);
    task_queue_init(&sharedRes->taskQueue);
    pthread_mutex_init(&sharedRes->mutex, NULL);
    pthread_cond_init(&sharedRes->cond, NULL);
    sharedRes->exitFlag = 0;
    return 0;
}

int thread_pool_init(threadPool_t *pThreadPool, int workernum) {
    pThreadPool->threadnum = workernum;
    pThreadPool->tidArr = (pthread_t*)calloc(workernum, sizeof(pthread_t));
    ERROR_CHECK(pThreadPool->tidArr, NULL, "calloc when create tid arr");
    return 0;
}


